// map.js
// 换成本地的服务器js文件即可
// http://ua.bigemap.com:30081/bmsdk/bigemap.js/v2.1.0/bigemap.js
let script = [
    "/bigemap/js/bigemap.js",
    "/js/jquery.min.js",
    // 海量点
    "/bigemap/js/glify.js",
    // 回访轨迹
    "/bigemap/js/moveMarker.js",
    "/bigemap/js/bm.geometryutil.js",
    //画画
    "/bigemap/js/bm-plot.min.js",
    //迁徙图
    "/echarts/echarts.min.js",
    "/bigemap/js/iclient9.min.js",//BM.supermap.echartsLayer 的依赖

];
let css = [
    "/bigemap/css/bigemap.css",
    // "http://ua.bigemap.com:30081/bmsdk/bigemap.js/v2.1.0/bigemap.css",
];
let baseUrl = process.env.BASE_URL;
export default new Promise(resolve => {
    //处理css
    css.map(cssHref => {
        let link = document.createElement('link');
        link.rel = 'stylesheet';
        link.async = false;
        if (cssHref.startsWith("http")) {
            link.href = cssHref;
        } else {
            link.href = baseUrl + cssHref;
        }
        document.head.appendChild(link);
    });
    //处理js
    let loads = script.map(srcUrl => {
        let script = document.createElement('script');
        script.type = 'text/javascript';
        script.async = false;
        if (srcUrl.startsWith("http")) {
            script.src = srcUrl;
        } else {
            script.src = baseUrl + srcUrl;
        }
        document.head.appendChild(script);
        return script;
    });
    let end = loads.pop();
    end.onload = resolve
})
